package MOLE.App;

import MOLE.*;

/** 
 Log ��ժҪ˵����
*/
public class Log
{

	public Log()
	{
		//
		// TODO: �ڴ˴���ӹ��캯���߼�
		//
	}


	public final void Add(String errmsg)
	{
		Add(1, errmsg);
	}


	public final void Add(int errcode, String errMsg)
	{
		MOLE.SQLOS o = new MOLE.SQLOS("log");
		o.RS("logErrcode", errcode);
		o.RS("logcontent", errMsg);
		o.Insert();
	}

	public final DataTable GetList(int count)
	{
		String s = "select top " + String.valueOf(count) + " * from log order by logid desc";
		DataTable dt = MOLE.SQL.GetDataTable(s);
		return dt;
	}

	public static void Add(String msg, String demo)
	{
		String s = System.Web.HttpContext.Current.Server.MapPath("/");
		s = s + "_log/index.html";
		String path = s;

		String encode = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";

		String rn = "\r\n<br>\r\n";
		 String str = encode + rn;
		str += "--------------------" + rn;
		str += "  I D:  " + MOLE.comm.getRandom(4) + rn;
		str += " TIME:  " + java.time.LocalDateTime.now().toString() + rn;
		str += "  TITLE: " + msg + rn;
		str += demo + rn;
		str += "--------------------" + rn;


		MOLE.file.write(path, str);


	}

	public static void AddDB(String msg, String demo)
	{
		 String encode = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";

		String rn = "\r\n<br>\r\n";
		String str = encode + rn;
		str += "--------------------" + rn;
		str += "  I D:  " + MOLE.comm.getRandom(4) + rn;
		str += " TIME:  " + java.time.LocalDateTime.now().toString() + rn;
		str += "  TITLE: " + msg + rn;
		str += demo + rn;
		str += "--------------------" + rn;


		MOLE.SQLOS o = new SQLOS("log");
		o.RS("LogCode", 1);
		o.RS("LogMsg", msg);
		o.RS("logcontent", str);
		o.Insert();

	}



}